import docker
from docker.models.containers import Container

client = docker.from_env()


def list_containers(all=False) -> list[Container]:
    return [container for container in client.containers.list(all=all)]


def start_container(container_name):
    container = client.containers.get(container_name)
    container.start()


def stop_container(container_name):
    container = client.containers.get(container_name)
    container.stop()


def create_container(image_name, container_name):
    return client.containers.run(image_name, name=container_name, detach=True)
